#include<iostream>
#include<unistd.h>
#include<cassert>
#include<vector>

using namespace std;

const int num = 5;

struct channl
{
    int fdw;
    pid_t workerid;
    string name;

    channl(int fd,pid_t id)
        :fdw(fd),workerid(id)
    {
        name = "channl-"+ (id-getpid())-'0';
    }
};


void creatpool()
{

}

void work()
{
    //
}

int main()
{
    vector<channl> channls;
    //创建管道和进程
    int i = 0;
    for(;i<num;i++)
    {
        //创建管道
        int pipefd[2] = {0};
        int n = pipe(pipefd);
        assert(n == 0);
        (void)n;
        
        //创建进程
        int id = fork();
        if(id < 0) return 1;
        if(id == 0)
        {
            close(pipefd[1]);
            dup2(pipefd[0],0);
            work();
            exit(0);
        }

        close(pipefd[0]);
        channls.push_back(channl(pipefd[1],id));
        
            
        
    }

    return 0;
}
